package io.lckgroup.modules.lck.controller.app;

import io.lckgroup.common.utils.PageUtils;
import io.lckgroup.common.utils.R;
import io.lckgroup.modules.lck.annotation.AppLogin;
import io.lckgroup.modules.lck.annotation.AppLoginUser;
import io.lckgroup.modules.lck.entity.CommonCommentEntity;
import io.lckgroup.modules.lck.entity.ShopMerchantInfoEntity;
import io.lckgroup.modules.lck.service.CommonCommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * APP Do评论信息表
 *
 * @author srq
 * @email siruiqi@siruiqi.com
 * @date 2020-2-6 16:21:51
 */
@RestController
@RequestMapping("/app/shopComment")
@Api("APP评论信息表")
public class AppCommonCommentController {

    @Autowired
    private CommonCommentService commonCommentService;

    /**
     * 获取当前登录用户的评论信息
     *
     * @param params
     * @param sm
     * @return R
     */
    @AppLogin
    @GetMapping("getList")
    @ApiOperation("获取评论信息的列表")
    public R getList(@RequestParam Map<String, Object> params, @AppLoginUser ShopMerchantInfoEntity sm) {
        //需要传入一个page和limit
        ShopMerchantInfoEntity merchant = sm;
        CommonCommentEntity cce = new CommonCommentEntity();
        cce.setMerchantId(merchant.getId());
        PageUtils queryPage = commonCommentService.queryPageByEntity(params, cce);
        return R.ok().put("results", queryPage);
    }

    /**
     * 获取当前登录商家信息
     *
     * @param shopMerchantInfoEntity
     * @return R
     */
    @AppLogin
    @RequestMapping("getMerchantInfo")
    public R getMerchantInfo(@AppLoginUser ShopMerchantInfoEntity shopMerchantInfoEntity) {
        return R.ok().put("merchantInfo", shopMerchantInfoEntity);
    }


}
